package com.first.config.mybatis;

import java.sql.Statement;
import java.util.Properties;

import org.apache.ibatis.executor.statement.StatementHandler;
import org.apache.ibatis.plugin.Interceptor;
import org.apache.ibatis.plugin.Intercepts;
import org.apache.ibatis.plugin.Invocation;
import org.apache.ibatis.plugin.Plugin;
import org.apache.ibatis.plugin.Signature;
import org.apache.ibatis.session.ResultHandler;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@Intercepts(
	    {
	        @Signature(type = StatementHandler.class, method = "query", args = {Statement.class,  ResultHandler.class}),
	    }
	)
//http://www.cnblogs.com/daxin/p/3541922.html
//Mybatis支持对Executor、StatementHandler、PameterHandler和ResultSetHandler进行拦截，也就是说会对这4种对象进行代理。
public class MySelfInterceptor  implements Interceptor{

	 private static final Logger LOGGER = LoggerFactory.getLogger(MySelfInterceptor.class);
	 
	@Override
	public Object intercept(Invocation invocation) throws Throwable {
		LOGGER.info("lalalalalal");
		return invocation.proceed();
	}

	@Override
	public Object plugin(Object target) {
		LOGGER.info("大声道撒多撒多");
	      return Plugin.wrap(target, this);
	}

	@Override
	public void setProperties(Properties properties) {
		LOGGER.info("大声道撒多撒多aaaaaaaaaaaaaa");
	}

}
